package com.truongnha.clienttn.presentation.adapter;

import java.util.List;

import com.truongnha.clienttn.R;
import com.truongnha.clienttn.business.model.ASubjectMarkModel;

import android.app.Activity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

public class StudentMarkAdapter extends ArrayAdapter<ASubjectMarkModel> {
	private final List<ASubjectMarkModel> list;
	private final Activity context;

	public StudentMarkAdapter(Activity context, List<ASubjectMarkModel> list) {
		super(context, R.layout.student_mark_item, list);
		this.context = context;
		this.list = list;
	}

	static class ViewHolder {
		protected TextView subjectName;
		protected TextView mark;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		View view = null;
		if (convertView == null) {
			LayoutInflater inflator = context.getLayoutInflater();
			view = inflator.inflate(R.layout.student_mark_item, null);
			final ViewHolder viewHolder = new ViewHolder();

			viewHolder.subjectName = (TextView) view.findViewById(R.id.subject_name);
			viewHolder.mark = (TextView) view.findViewById(R.id.mark);
			view.setTag(viewHolder);
		} else {
			view = convertView;
		}
		ViewHolder holder = (ViewHolder) view.getTag();
//		switch (list.get(position).getType()) {
//		case 3:
//			holder.status.setTextColor(Color.rgb(204, 0, 0));
//			// holder.index.setTextColor(Color.rgb(204, 0, 0));
//			holder.time.setTextColor(Color.rgb(204, 0, 0));
//			holder.status.setText("KhÃ´ng phÃ©p");
//			break;
//		case 2:
//			holder.status.setTextColor(Color.rgb(58, 135, 173));
//			// holder.index.setTextColor(Color.rgb(58, 135, 173));
//			holder.time.setTextColor(Color.rgb(58, 135, 173));
//			holder.status.setText("Ä�i muá»™n");
//			break;
//		case 1:
//			holder.status.setTextColor(Color.rgb(70, 136, 71));
//			// holder.index.setTextColor(Color.rgb(70, 136, 71));
//			holder.time.setTextColor(Color.rgb(70, 136, 71));
//			holder.status.setText("CÃ³ phÃ©p");
//			break;
//		default:
//			holder.status.setText(" ");
//			break;
//		}
			
		holder.subjectName.setText(list.get(position).getName());
		holder.mark.setText(list.get(position).getMarkToString());
		return view;
	}// end getView
}
